# coding=utf8
# self import statement allows access to the karamba functions
# simply vCard parser, 
# currently only handle, names, mails and phones

# license: GPL
# author: Pavel Nemec <pnemec@suse.cz>
# 2007-06-29 HACK WEEK
import karamba
import os
import sys
import readvcard
import string
import usercal

mailCommand=["kmail" ,"-s New message for you"]
kopeteListCommand=["dcop --pipe","kopete" ,"KopeteIface", "onlineContacts"]
##kopeteInvokeCommand=[ nothnink for now]
clipBoardCommand=["dcop", "klipper" ,"klipper" ,"setClipboardContents"]
phoneCommand="echo " #no command for now
kabCommand=["kaddressbook"]

theme="basic"
defaultvCal=os.path.expanduser("~")+"/.kde/share/apps/kabc/std.vcf"
userPicturePath="images/"+theme

textAreaPositionX=20
textAreaPositionY=50
maxAppletHeight=240
minAppletHeight=75
appletWidth=200
numberOfItems=8
cfgPosX=185
cfgPosY=minAppletHeight-15
cfgPoMaxY=150
inputBoxXPos=40
inputBoxYPos=15
inputBoxLength=130
fontSize=12
fontSizeBig=15
footerHeight=18
global background
global mousex
global mousey
global mainClass

def initWidget(widget):
    global mainClass
    mainClass = KadressBookGui(widget)
    mainClass.addFileNoStore(defaultvCal)
    for i in usercal.getUserCalFiles():
        mainClass.addFileNoStore(i)
    

def meterClicked(widget, meter, button):
    global mainClass
    mainClass.mouseEvent(meter,button)
    
    
def widgetUpdated(widget):
    pass

def widgetClicked(widget, x, y, button):
	pass

def widgetMouseMoved(widget, x, y, button):
    global mousex, mousey
    mousex=x
    mousey=y
    mainClass.mouseOver(x,y,)

def keyPressed(widget, meter, char):
    mainClass.keyboradEvent(meter,char)		

# program i called, return me somethink
def commandOutput(widget, pid, output):
	pass;
		

def getImage(imageName):
    return "images/"+theme+"/"+imageName


class KadressBookGui:
    
    #searchInputBox
    def __init__(self,widget):
        self.w=widget
        self.initTextAreas()   
        self.initVariables()
        
        self.NAME=0
        self.PHONE=1
        self.MAIL=2
        self.IM=3
        print "i have items: ",self.searcher.getItemCount()
        
        
        
    def initVariables(self):
        self.idstack=[]
        tmpY=textAreaPositionY+10
        for i in range(numberOfItems):
            item=range(5)
            item[0]="" #string
            itembg = karamba.createImage(self.w,textAreaPositionX,tmpY,"images/list_full.png")
            karamba.hideImage(self.w,itembg);
            karamba.attachClickArea(self.w,itembg,"")
            item[1]=itembg #clickable background
            itemtext= karamba.createText(self.w,textAreaPositionX+10,tmpY,140,15,"")
            karamba.hideText(self.w,itemtext)
            item[2]=itemtext#text
            item[3]=-1 #id
            item[4]=[-1] #custom data
            self.idstack.append(item)
            tmpY+=20
            
        self.customImages=[] #images generated during search they are karamba image !
        self.bigAreaTexts=[]
        self.itemsPerPage=10
        self.positionInStack=0
        self.view="small"
        self.fakeUserPicture = karamba.createImage(self.w,5,5,getImage("kuser.png"))
        self.searchInputBox = karamba.createInputBox(self.w, inputBoxXPos, inputBoxYPos, inputBoxLength, 23, "")
        karamba.changeInputBoxFrameColor(self.w,self.searchInputBox,72,139,141)
        self.searchPicture = karamba.createImage(self.w,inputBoxXPos+inputBoxLength+5,inputBoxYPos,getImage("search.png"))
        karamba.attachClickArea(self.w,self.searchPicture)
        self.searcher = readvcard.ReadVcard()
        self.background = karamba.createBackgroundImage(self.w, 0, 0, "images/background_small.png")
        print "adding files ", getImage("footer.png")
        
        self.footerText=karamba.createText(self.w,appletWidth/2, minAppletHeight-footerHeight,60,215,"")
        self.footerRightArrow = karamba.createImage(self.w,appletWidth/2+20,minAppletHeight-footerHeight,getImage("rightarrow.png"))
        self.footerLeftArrow  = karamba.createImage(self.w,appletWidth/2-20,minAppletHeight-footerHeight,getImage("leftarrow.png"))
        self.footer = karamba.createImage(self.w, 0, minAppletHeight-footerHeight, getImage("footer.png"))
        karamba.attachClickArea(self.w,self.footerLeftArrow)
        karamba.attachClickArea(self.w,self.footerRightArrow)    
        self.needle=-1
        

        self.files=[] #files with vCal files
        
        #configure view
        self.cfg = range(3)
        self.cfg[0]=karamba.createImage(self.w,cfgPosX,cfgPosY,getImage("circle.png"))
        self.cfg[1]=karamba.createImage(self.w,cfgPosX,cfgPosY,getImage("circle_bold.png"))
        karamba.attachClickArea(self.w,self.cfg[1],"")
        karamba.attachClickArea(self.w,self.cfg[0],"")
        karamba.hideImage(self.w,self.cfg[1])
        self.configurator= Configuration(self.w)
        
        #
        # add all files tored by karamba facility
        tmpfiles=karamba.readConfigEntry(self.w,"files")
        if tmpfiles==None:
            print "no files stored"
        else:
            self.files=tmpfiles.split()
            for i in self.files:
                self.searcher.addFile(i)
        
        
    def keyboradEvent(self, component,key):
        #fix concept bug
        if self.view=="cfg":
            self.switchTextAreaN("small")
            return
        #print "have and key event", component, " ", self.searchInputBox
        text=""
        if component == self.searchInputBox:
            text = karamba.getInputBoxValue(self.w, self.searchInputBox)
        else:
            #focus is not on input box, but who care ! ;)
            text = karamba.getInputBoxValue(self.w, self.searchInputBox)
            text=text+key
            karamba.changeInputBox(self.w, self.searchInputBox,text)
            karamba.setInputFocus(self.w,self.searchInputBox) #just for sure ;)
            
        if len(text) >0:
            if self.view != "big": self.switchTextAreaN("big")
            self.searchForText(text)
        else:
            self.switchTextAreaN("small")
        
        pass;
        
    def mouseEvent (self, component, button):
        print "have mouse event: ",component
        if self.view !="contact":
            for i in range(len(self.idstack)):
                item=self.idstack[i] #0 string, 1 bg, 2 texta
                
                itembg=item[1]
                if itembg == component:
                            self.searchContact(item[3])
        else:
             for i in range(len(self.idstack)):
                item=self.idstack[i] #0 string, 1 bg, 2 texta 3 id
                itembg=item[1]
                if itembg == component:
                    id=item[3]
                    if id==self.NAME:
                        self.executeCommand(clipBoardCommand,item[0])
                        self.callName(item[0])
                    if id==self.MAIL:
                        self.writeMail(item[0])
                        self.executeCommand(clipBoardCommand,item[0])
                    if id==self.PHONE:
                        self.executeCommand(clipBoardCommand,item[0])
                        self.callPhone(item[0])
                    if id==self.IM:
                        self.executeCommand(clipBoardCommand,item[0])
                        self.callIM(item[0])
        if component==self.cfg[1]:
            print "have and cfg event, view is: ",self.view
            if self.view=="cfg":
                self.switchTextAreaN("small")
                karamba.moveImage(self.w,self.cfg[0],cfgPosX,cfgPosY)
                karamba.moveImage(self.w,self.cfg[1],cfgPosX,cfgPosY)
            else:
                self.switchTextAreaN("cfg")
                karamba.moveImage(self.w,self.cfg[0],cfgPosX,maxAppletHeight-15)
                karamba.moveImage(self.w,self.cfg[1],cfgPosX,maxAppletHeight-15)
        if component == self.searchPicture:
            karamba.changeInputBox(self.w,self.searchInputBox,"")
            self.switchTextAreaN("small")
        if self.view=="cfg":
            #delegate clickable
            self.configurator.mouseEvent(component)
        if component== self.footerLeftArrow:
            print "left arrow clicked"
            self.needle-=1
            if(self.needle<=-1):
                self.needle=self.searcher.getItemCount()-1    
            karamba.changeText(self.w,self.footerText,str(self.needle))
            self.fillContact(self.needle)
        if component== self.footerRightArrow:
            print "right arrow clicked"
            self.needle+=1
            if(self.needle>=self.searcher.getItemCount()-1):
                self.needle=0
            karamba.changeText(self.w,self.footerText,str(self.needle))
            self.fillContact(self.needle)
            
    def initTextAreas(self):
        #self.textArea = karamba.createImage(self.w,textAreaPositionX+40,textAreaPositionY-15,"images/textarea_background.png")
        self.infoText = karamba.createText(self.w,textAreaPositionX,textAreaPositionY-10,120,20,"Welcome to kabSA")
        self.bigTextArea = karamba.createImage(self.w,textAreaPositionX,textAreaPositionY,"images/textareaBig_background.png")
        karamba.hideImage(self.w, self.bigTextArea)

    def switchTextAreaN(self,kind):
        self.view=kind
        self.switchTextArea()
    def switchTextArea(self):
        print "self view is: ",self.view
        self.cleanBigTextArea()
        if self.view == "small":
            karamba.hideImage(self.w, self.bigTextArea)
            #karamba.showImage(self.w, self.textArea)
            karamba.showText(self.w, self.infoText)
            karamba.deleteImage(self.w,self.background)
            self.background = karamba.createBackgroundImage(self.w, 0, 0, "images/background_small.png")
            karamba.setImagePath(self.w,self.searchPicture,getImage("search.png"))
            karamba.resizeWidget(self.w,appletWidth,minAppletHeight)
            karamba.showImage(self.w,self.cfg[0])
            karamba.showImage(self.w, self.fakeUserPicture)
            self.moveFooter(0,minAppletHeight-footerHeight)
        elif self.view== "big" or self.view=="contact":
            #karamba.hideImage(self.w, self.textArea)
            karamba.showImage(self.w, self.bigTextArea)
            karamba.hideText(self.w, self.infoText)
            karamba.deleteImage(self.w,self.background)
            karamba.hideImage(self.w,self.cfg[0])
            #karamba.moveImage(self.w,self.footer,0,maxAppletHeight-18)
            karamba.setImagePath(self.w,self.searchPicture,"images/"+theme+"/erase.png")
            self.background = karamba.createBackgroundImage(self.w, 0, 0, "images/background_big.png")
            karamba.resizeWidget(self.w,appletWidth,maxAppletHeight)
            self.moveFooter(0,maxAppletHeight-footerHeight)
        if self.view=="cfg":
            karamba.hideInputBox(self.w,self.searchInputBox)
            karamba.hideImage(self.w,self.searchPicture)
            #karamba.hideImage(self.w, self.textArea)
            karamba.hideImage(self.w,self.fakeUserPicture)
            karamba.hideText(self.w, self.infoText)
            karamba.deleteImage(self.w,self.background)
            self.background = karamba.createBackgroundImage(self.w, 0, 0, "images/background_big.png")
            karamba.resizeWidget(self.w,appletWidth,maxAppletHeight)
            self.showFooter(False)
            self.configurator.show()
        else:
            karamba.showInputBox(self.w,self.searchInputBox)
            karamba.showImage(self.w,self.searchPicture)
            self.configurator.hide()
            self.showFooter(True)
            # not needed as i fix it in keyEvent method
            karamba.moveImage(self.w,self.cfg[0],cfgPosX,cfgPosY)
            karamba.moveImage(self.w,self.cfg[1],cfgPosX,cfgPosY)
    def moveFooter(self,x,y):
        print "moving footer to ",y
        karamba.moveImage(self.w,self.footer,x,y)
        
        #do not move arrows in X-axe, self is done elsewhere 
        karamba.moveImage(self.w,self.footerRightArrow,karamba.getImagePos(self.w,self.footerRightArrow)[0],y)
        karamba.moveImage(self.w,self.footerLeftArrow, karamba.getImagePos(self.w,self.footerLeftArrow)[0],y)
        karamba.moveText(self.w,self.footerText,appletWidth/2,y)
    def showFooter(self,visible):    
        if(visible==False):
            karamba.hideImage(self.w,self.footer)
            karamba.hideImage(self.w,self.footerLeftArrow)
            karamba.hideImage(self.w,self.footerRightArrow)
            karamba.hideText(self.w,self.footerText)
        else:
            karamba.showImage(self.w,self.footer)
            karamba.showImage(self.w,self.footerLeftArrow)
            karamba.showImage(self.w,self.footerRightArrow)
            karamba.showText(self.w,self.footerText)
        
    def cleanBigTextArea(self):
        for i in self.idstack:
            string=i[0]
            image=i[1]
            text=i[2]
            karamba.hideImage(self.w,image)
            karamba.hideText(self.w,text)
            karamba.changeTextSize(self.w,text,fontSize)
        for i in self.customImages:
            karamba.deleteImage(self.w,i)
        self.customImages=[]
    def searchForText(self, text):
        found = self.searcher.search(text)
        print "i have found ", len(found), " items"
        if self.view=="small": self.switchTextAreaN("big")
        else: self.cleanBigTextArea()
        
        if len(found)>1:
            self.fillItems(found)
        elif len(found)==1: 
            self.fillContact(found[0][0])
        
    def fillContact(self, contactID):
        if self.view!="contact": self.switchTextAreaN("contact")
        self.cleanBigTextArea()
        contact=self.searcher.getContact(contactID)
        if contact==None:
            print "kab.fillContact: cannot get Contact for id: ",contactID
            return
        
        karamba.changeText(self.w,self.footerText,str(contactID))
        self.needle=contactID
    
        name=contact.jmeno
        phones = contact.phoneList
        mails=contact.mailList
        ims=contact.imList #instant messangers
        index=0
        #name
        idItem = self.idstack[index]
        index+=1
        idItem[0]=name
        idItem[3]=self.NAME
        print "filling contact ",name, " with phones ",len(phones), ", mails ",len(mails), " and ims: ",len(ims)
        karamba.showImage(self.w,idItem[1]) #show image
        karamba.changeTextSize(self.w,idItem[2],fontSizeBig)
        karamba.addImageTooltip(self.w,idItem[1],"Open Kaddressbook, midle click to copy names into search field")
        karamba.changeText(self.w,idItem[2],"  " + idItem[0]) #change text from item
        karamba.showText(self.w,idItem[2]) #show text
#        karamba.changeInputBox(self.w,self.searchInputBox,name)
        #karamba.changeInputBoxSelection(self.w,self.searchInputBox,0,5)
        
##        max 5 phones
        for i in range(0,min(4,len(phones))):
            #print "writing phone on position ",i
            phone=phones[i]
            idItem = self.idstack[index]
            index+=1
            idItem[0]=phone[1]
            idItem[3]=self.PHONE
            karamba.showImage(self.w,idItem[1]) #show image
            karamba.addImageTooltip(self.w,idItem[1],"Copy phone number to clipboard")
            karamba.changeText(self.w,idItem[2],"     "+idItem[0]) #change text from item
            karamba.showText(self.w,idItem[2]) #show text
            position=karamba.getImagePos(self.w,idItem[1])
            customImage = karamba.createImage(self.w,position[0],position[1],getImage("phone.png"))
            self.customImages.append(customImage)
        
        for i in range(0,min(4,len(mails))):
            #print "writing mail on position ",i
            mail=mails[i]
            idItem = self.idstack[index]
            index+=1
            idItem[0]=mail[1]
            idItem[3]=self.MAIL
            karamba.showImage(self.w,idItem[1]) #show image
            karamba.addImageTooltip(self.w,idItem[1],"Copy adress to clipboard and create new mail")
            karamba.changeText(self.w,idItem[2],"   "+idItem[0]) #change text from item
            karamba.showText(self.w,idItem[2]) #show text    
            position=karamba.getImagePos(self.w,idItem[1])
            customImage = karamba.createImage(self.w,position[0],position[1],getImage("mail.png"))
            self.customImages.append(customImage)
        for i in range(0,min(4,len(ims))):
            #print "writing mail on position ",i
            im=ims[i]
            idItem = self.idstack[index]
            index+=1
            idItem[0]=im[1]
            idItem[3]=self.IM
            karamba.showImage(self.w,idItem[1]) #show image
            karamba.addImageTooltip(self.w,idItem[1],"Copy IM name to clipboard")
            karamba.changeText(self.w,idItem[2],"   "+idItem[0]) #change text from item
            karamba.showText(self.w,idItem[2]) #show text    
            position=karamba.getImagePos(self.w,idItem[1])
            customImage = karamba.createImage(self.w,position[0],position[1],getImage("kopete_small.png"))
            self.customImages.append(customImage)
    #there is bug here, i am throwing OUT all items which do not fit into numberOfItems !!
    def fillItems(self, items):
        for i in range(min(numberOfItems,len(items))):
            idItem = self.idstack[i]
            item=items[i]
            idItem[0]=item[1] #pass the text
            idItem[3]=item[0] #pass the id
            karamba.showImage(self.w,idItem[1]) #show image
            karamba.changeText(self.w,idItem[2],idItem[0]) #change text from item
            karamba.showText(self.w,idItem[2]) #show text
            
    def searchContact(self, id):
        contact = self.searcher.getContact(id)
        if contact == None:
            print "return null"
        else:
            self.fillContact(id)
    
    def callPhone(self, phone):
        print "going to handle phone number: ",phone
    def callIM(self, im):
        print "going to handle IM: ",im
        print "should call some dcop...later"
    def callName(self, name):
        #is adressbook running? or not? just do not care and call it
        karamba.executeInteractive(self.w,kabCommand)
    def writeMail(self, adress):
        print "going to write email to adress: ",adress
        self.executeCommand(mailCommand,adress)
    def executeCommand(self,command,variable):
        mycommand=command
        mycommand.append(variable)
        karamba.executeInteractive(self.w,mycommand)
        mycommand.pop()
    def mouseOver(self,x, y):
        if self.view=="small":
            #cfg
##            print "mouse over"
            if abs(x-cfgPosX)<7 and abs(y-cfgPosY)<7:
                karamba.hideImage(self.w,self.cfg[0])
                karamba.showImage(self.w,self.cfg[1])
                self.cfg[2]=1
            elif self.cfg[2]==1:
                self.cfg[2]=0
                karamba.hideImage(self.w,self.cfg[1])
                karamba.showImage(self.w,self.cfg[0])
                
    def addFile(self,file):
        print "adding file: ",file
        self.searcher.addFile(file)
        self.files.append(file)
        print "now have files: ",self.files
        tmpfile =  string.join(self.files," ")
        karamba.writeConfigEntry(self.w,"files",tmpfile)
        self.parseFiles()
    def addFileNoStore(self,file):
        print "adding file without storing ",file
        self.searcher.addFile(file)
        self.parseFiles()
    def deleteAllFiles(self):
        self.files=[]
        karamba.writeConfigEntry(self.w,"files","")
        
    def parseFiles(self):
        '''
            reparse newly added files, remove duplicite (todo), and correct position of arrows
        '''
        self.searcher.parseNewFiles()
        size=len(str(self.searcher.getItemCount()))  #how many contacts we have, messured in character length
        size*=fontSize
        print "size is", size
        karamba.changeText(self.w,self.footerText,str(self.searcher.getItemCount()))
        karamba.moveImage(self.w,self.footerLeftArrow,appletWidth/2-size/2,karamba.getImagePos(self.w,self.footerLeftArrow)[1])
        karamba.moveImage(self.w,self.footerRightArrow,appletWidth/2+size,karamba.getImagePos(self.w,self.footerRightArrow)[1])
      
        
class Configuration:
    def __init__(self,widget):
        #images are 32x32
        #start x=textAreaPositionX
        #start y=textAreaPositionY
        # KISS !!
        self.w=widget
        self.images=[] #karamba references to image
        self.texts=[] #karamba references to text
        #files
        y=10
        yesX=120
        noX=140
        #Header
        self.headertext=karamba.createText(self.w,textAreaPositionX,y+10,120,15,"Configuration menu")
        karamba.changeTextSize(self.w,self.headertext,13)
        self.texts.append(self.headertext)
        #icon
        self.help=karamba.createImage(self.w,textAreaPositionX+yesX,y,getImage("help.png"))
        karamba.attachClickArea(self.w,self.help)
        self.images.append(self.help)
        y+=60
        
        
        #open file
        self.open=karamba.createImage(self.w,textAreaPositionX,y,getImage("kuser_small.png"))
        self.images.append(self.open)
        #text
        self.filetext=karamba.createText(self.w,textAreaPositionX+30,y,100,15,"Add vCal file")
        self.texts.append(self.filetext)
        
        #yes
        self.fileOpen=karamba.createImage(self.w,textAreaPositionX+yesX,y,getImage("fileopen.png"))
        karamba.attachClickArea(self.w,self.fileOpen)
        karamba.addImageTooltip(self.w,self.fileOpen,"Open new vCal files.")
        self.images.append(self.fileOpen)
        #no
        self.fileDelete=karamba.createImage(self.w,textAreaPositionX+noX,y,getImage("close.png"))
        karamba.attachClickArea(self.w,self.fileDelete)
        karamba.addImageTooltip(self.w,self.fileDelete,"Delete all stored vCal files.")
        self.images.append(self.fileDelete)
        y+=35
        
        #kmail
        self.kmail=karamba.createImage(self.w,textAreaPositionX,y-5,getImage("kmail.png"))
        self.images.append(self.kmail)
        #
        #text
        self.mailtext=karamba.createText(self.w,textAreaPositionX+30,y,100,15,"Enable Kmail")
        self.texts.append(self.mailtext)
        
        #yes
        self.kmailYes=karamba.createImage(self.w,textAreaPositionX+yesX,y,getImage("ok.png"))
        karamba.attachClickArea(self.w,self.kmailYes)
        self.images.append(self.kmailYes)
        #no
        self.kmailNo=karamba.createImage(self.w,textAreaPositionX+noX,y,getImage("no.png"))
        karamba.attachClickArea(self.w,self.kmailNo)
        self.images.append(self.kmailNo)
        y+=35
        
        #kopete
        self.kopete=karamba.createImage(self.w,textAreaPositionX,y-5,"images/"+theme+"/kopete.png")
        self.images.append(self.kopete)
        #
        #text
        self.kopeteText=karamba.createText(self.w,textAreaPositionX+30,y,100,15,"Enable Kopete")
        self.texts.append(self.kopeteText)
        
        #yes
        self.kopeteYes=karamba.createImage(self.w,textAreaPositionX+yesX,y,getImage("ok.png"))
        karamba.attachClickArea(self.w,self.kopeteYes)
        self.images.append(self.kopeteYes)
        #no
        self.kopeteNo=karamba.createImage(self.w,textAreaPositionX+noX,y,getImage("no.png"))
        karamba.attachClickArea(self.w,self.kopeteNo)
        self.images.append(self.kopeteNo)
        y+=35
        
        
        
        #Theming
        self.umicon=karamba.createImage(self.w,textAreaPositionX+10,maxAppletHeight-30,"images/umicon_unselected.png")
        self.aqua=karamba.createImage(self.w,textAreaPositionX+60,maxAppletHeight-30,"images/aqua_selected.png")
        
        self.crystal=karamba.createImage(self.w,textAreaPositionX+100,maxAppletHeight-30,"images/crystal_unselected.png")
        
        karamba.attachClickArea(self.w,self.aqua)
        karamba.attachClickArea(self.w,self.crystal)
        karamba.attachClickArea(self.w,self.umicon)
        self.images.append(self.aqua)
        self.images.append(self.crystal)
        self.images.append(self.umicon)
        self.hide()
        
    def hide(self):
        for i in self.images:
            karamba.hideImage(self.w,i)
        for i in self.texts:
            karamba.hideText(self.w,i)
    def show(self):
        for i in self.images:
            karamba.showImage(self.w,i)
        for i in self.texts:
            karamba.showText(self.w,i)
    def mouseEvent(self,component):
        print "configurator have an event"
        c=component
        #who have event?
        if c==self.help:
            cin,cout = os.popen2("konqueror help/index.html")
            lines = cout.read()
            cin.close()
            cout.close()
        elif c==self.fileOpen:
            print "open file"
            cin,cout = os.popen2("kfiledialog --files")
            lines = cout.read()
            cin.close()
            cout.close()
            files= lines.split()
            for i in files:
                file=i.replace("\n","")
                mainClass.addFile(i)
                print "parsing file: ",file
        elif c==self.fileDelete:
            mainClass.deleteAllFiles()
            print "deleteFile"
        elif c==self.kmailYes:
            print "kmail yes"
        elif c==self.kmailNo:
            print "kmail NO"
        elif c==self.kopeteYes:
            print "kopete yes"
        elif c==self.kopeteNo:
            print "kopete no"
        elif c==self.aqua:
            print "aqua"
        elif c==self.crystal:
            print "crystal"
        elif c==self.umicon:
            print "umicon"
        else:
            print "unknown"
